
enable_language(Fortran)


# 添加mc64的Fortran源文件
file(GLOB MC64_SOURCES
    "./mc64/*.f"
    "./mc64/*.f90"
)

# 创建Fortran静态库
add_library(mc64 STATIC
    ${MC64_SOURCES}
)

# 设置Fortran编译选项
target_compile_options(mc64 PRIVATE -O3)
set_target_properties(mc64 PROPERTIES
    Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/modules
)


add_library(
  libbtlu
  dreadrb.cpp
  fact.cpp
  get_perm.cpp
  matrix.cpp
  memory.cpp
  solve.cpp
  rcm.cpp
  Graph.cpp
  utils.cpp)

target_link_libraries(
  libbtlu
  PUBLIC ${BLAS_LIBRARIES}
  PRIVATE mc64)
target_include_directories(
  libbtlu PUBLIC 
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
    ${CMAKE_SOURCE_DIR}/src
    ${CMAKE_BINARY_DIR}/modules
  )

if(OPENMP_FOUND)
  target_compile_definitions(libbtlu PUBLIC -DOPENMP)
  target_link_libraries(libbtlu PRIVATE OpenMP::OpenMP_CXX)
endif()